/*LICENSE_BEGIN
 * ******************************************************************
 * All original parts of SoccerScope2003 have copyright (2003) by
 * Team YowAI, represented by Mr. Shuhei Shiota
 * The Department of Creative Informatics
 * The Graduate School of Information Science and Technology
 * The University of Tokyo
 * 
 * Additional classes (except libraries in /lib) were developed by 
 * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin 
 * (www.dai-labor.de)
 * 
 * Extended/new classes/packages are:
 *   soccerscope.analyzer.LogfileAnalyzer
 *   soccerscope.daistatistic.*
 *   soccerscope.daistatistic.charts.*
 *   soccerscope.daistatistic.tools.*
 *   soccerscope.db.*
 *   soccerscope.dialog.*
 *   soccerscope.model.PlayerWorldModel
 *   soccerscope.model.SimplePlayer
 *   soccerscope.net.AgentConnector
 *   soccerscope.training.*
 *   soccerscope.training.conditions.*
 * ******************************************************************
LICENSE_END*/
package soccerscope.daistatistic.tools;

import java.io.FileWriter;
import java.io.IOException;

/**
 * 
 * a txt writer
 */
public class TextWriter {

	/**
	 * 
	 * saves text lines to a file
	 * 
	 * @param String[]
	 *            the lines to save
	 * @param String
	 *            the file name without the .jpg extension
	 */
	public static void save(String[] lines, String nameWithoutExtension) {

		FileWriter fw = null;

		// try to write
		try {
			fw = new FileWriter(nameWithoutExtension + ".txt", true); // a new
			// file
			// writer
			// with
			// mode
			// append
			// =
			// true

			// write all lines to file
			for (int i = 0; i < lines.length; i++) {
				fw.write(lines[i] + "\n");
			}
			fw.write("\n");
		} catch (IOException e) {
			System.out.println("Konnte Datei nicht erstellen");
		} finally {
			try {
				if (fw != null)
					fw.close();
			} catch (IOException e) {
			}
		}
	}
}
